<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>统计字符串中含a或A的字符串个数</title>
	</head>
	<body>
		<script type="text/javascript">
			var string=new Array("Americal","Greece","Britain",
			"Canada","China","Egypt");
			var b=0;
			/*for(var i in string){
				document.write(string[i]+"<br />");
			}*/
			//注意在JavaScript中不在有具体的变量类型，不声明变量类型了
			for(var i=0;i<string.length;i++){
				document.write(string[i]+"<br />");
			}
			for(var i in string){
				if(string[i].indexOf("A")!=-1||string[i].indexOf("a")!=-1){
					b++
				}
			}
			document.write("字符串中含a或A的字符串个数为"+b);
		</script>
	</body>
</html>
